package network;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
        try {
            int port = 1080;
            ServerSocket server = new ServerSocket(port);
            Socket client = server.accept();
            PrintWriter out = new PrintWriter(client.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
            String entry;
            while ((entry = in.readLine()) != null) {
                System.out.println("Receive client message: " + entry);
                out.println(entry);
            }
            server.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
